
function cko_sell_item(name,num,bag,slot,start_copper,buyout_copper,hours)
  cko_print("Selling "..name.." x"..num..
		" for "..(start_copper/100).." ("..(buyout_copper/100)..") "
		..hours.." Hours")
  PickupContainerItem(bag,slot)
  ClickAuctionSellItemButton()
  StartAuction(start_copper-1,buyout_copper-1,hours*60) 
end

function cko_sell()
  for bag=0,4 do
    for slot=1,GetContainerNumSlots(bag) do
      x1 = GetContainerItemLink(bag,slot)
      if x1 then
        _,n=GetContainerItemInfo(bag,slot)
        for key,value in cko_price[GetRealmName()][UnitFactionGroup("player")] do
          if (string.find(x1,key)) then
            r = 1 - 0.1*random()
            cko_sell_item(
              key,
              n,
              bag,
              slot,
              0.5*value*n*r,
              value*n*r,
              24)
          end
        end
      end
	  	end
  end
end

